package youtube.tv.authentication

/**
 * @author Sergey Istomin
 */
class AuthenticationTagLib {
    def authenticationService
    def grailsApplication

    def socialLoginScript = { attrs, body ->
        if (!authenticationService.isLoggedIn()) {
            if (params['signed_request']) {
                out << """
                    <script>
                      var oauth_url = 'https://www.facebook.com/dialog/oauth/';
                      oauth_url += '?client_id=${grailsApplication.config.facebook.applicationId}';
                      oauth_url += '&redirect_uri=' + encodeURIComponent('http://apps.facebook.com/tv-youtube/');

                      window.top.location = oauth_url;
                    </script>"""
            }
        }
    }
}
